!a.get_profile().is_custom_build()
});
let bin = try!(bins.next().chain_error(|| {
- human("a bin target must be available for `cargo run`")
+ match (name.as_ref(), &target_kind) {
+ (Some(name), &TargetKind::Bin) => {
+ human(format!("no bin target named `{}` to run", name))
+ }
+ (Some(name), &TargetKind::Example) => {
+ human(format!("no example target named `{}` to run", name))
+ }
+ (Some(_), &TargetKind::Lib(..)) => unreachable!(),
+ (None, _) => human("a bin target must be available for `cargo run`"),
+ }
}));
match bins.next() {
Some(..) => return Err(
execs().with_status(0));
assert_that(&p.bin("foo"), existing_file());
});
+
+test!(bad_example {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/lib.rs", "");
+
+ assert_that(p.cargo_process("run").arg("--example").arg("foo"),
+ execs().with_status(101).with_stderr("\
+no example target named `foo` to run
+"));
+ assert_that(p.cargo_process("run").arg("--bin").arg("foo"),
+ execs().with_status(101).with_stderr("\
+no bin target named `foo` to run
+"));
+});